package com.py.pythink.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.py.pythink.entity.UserLike;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface UserLikeDao extends BaseMapper<UserLike> {
    //点赞帖子,先检查这个帖子，登陆用户是否已经点赞过
    //如果没有点赞，就点赞，点赞数+1，点赞了就取消点赞
    //需要的参数有帖子的fuid，登陆用户的uid
//    @Select("select * from t_userlike where fuid =#{fuid} and uid=#{uid}")
//    int djok(@Param("fuid") int fuid,@Param("uid") int uid );

//    @Select("select * from t_userlike uu inner join t_usersend us uu.fuid=us.id")
//    UserLike getUserLike(@Param("fuid") int fuid,@Param("uid") int uid);

    //修改
    @Update("update t_userlike set flag=#{flag} where fuid=#{fuid}")
    int udate( int flag ,int fuid);

    //查询无状态 新增一条点赞记录
    @Insert("insert into t_userlike(uid,fuid,flag) values(#{uid},#{fuid},1)")
    int insert(UserLike userLike);

    //
    @Select("select * from t_userlike where fuid=#{fuid} and uid=#{uid}")
    UserLike getInstance(int fuid,int uid);


}
